Output only characters between [ABC] and [/ABC]

Posted by user564530 on Stack Overflow See other posts from Stack Overflow or by user564530
Published on 2011-01-05T20:28:52Z Indexed on 2011/01/05 20:53 UTC
Read the original article Hit count: 232

Filed under:
|
$ cat somefile.txt
afsdfv
asdf[ABC]dafga
asdfasf
yxcvyxv[/ABC]
asdadf
yv[ABC]sdfb
sdfgadfg
[/ABC]adf
asdf
$ cat somefile.txt | NEEDEDONELINER > output.txt
dafga
asdfasf
yxcvyxv
sdfb
sdfgadfg
$

So the "NEEDEDONELINER" only outputs the characters between a [ABC] and [/ABC].

[ABC] could occur several times, and there could be random characters around it.

I only need the random chars between the [ABC] and [/ABC].

I don't have time to learn Perl :\

Thank you in anticipiation!

© Stack Overflow or respective owner

Related posts about perl

Related posts about scripting